import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getDevAPI, getDevCountAPI } from '@/apis/device'
import { addRoomDevsAPI } from '@/apis/room'

export const useDevStore = defineStore('dev', () => {
    // state
    const devInfo = ref([])
    const devTotlCount = ref()

    const getDevData = async (param) => {
        const res = await getDevAPI(param)
        devInfo.value = res.data.data
    }

    const getTotlCount = async () => {
        const res = await getDevCountAPI()
        devTotlCount.value = res.data.data
    }

    const addRoomDevs = async (data) => {
        const res = await addRoomDevsAPI(data)
        console.log(res.data.data)
    }

    return {
        devInfo,
        getDevData,
        getTotlCount,
        devTotlCount,
        addRoomDevs
    }
})